package com.woniuxy.thred.state;

/**
 * description: YieldDemo01 <br>
 * date: 2022/2/5 6:10 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

/**
 * yield礼让线程，暂停线程 直接进入就绪状态不是阻塞状态
 */
public class YieldDemo01 {
    public static void main(String[] args) {
        MyYield my = new MyYield();
        new Thread(my, "a").start();
        new Thread(my, "b").start();
    }
}

class MyYield implements Runnable {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "-->start");
        Thread.yield();//礼让
        System.out.println(Thread.currentThread().getName() + "-->end");
    }
}
